/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  router.prefix('/api')
  //user
  router.post('/user/register', controller.user.register);
  router.post('/user/login', controller.user.login);
  router.get('/user/list/:page/:pagesize',app.middleware.jwtValidator() ,controller.user.list);
  router.post('/user/avator', app.middleware.jwtValidator(),controller.user.uploadavater);
  router.put('/user/update', app.middleware.jwtValidator(),controller.user.updateuser);
  router.get('/user/info/:userid', app.middleware.jwtValidator(false),controller.user.getuserinfo);
  router.get('/user/subscribe/:subscribeid',app.middleware.jwtValidator(),controller.user.subscribe)
  router.get('/user/dissubscribe/:subscribeid',app.middleware.jwtValidator(),controller.user.dissubscribe)
  router.get('/user/subscribes',app.middleware.jwtValidator(),controller.user.subscribelist)
  router.get('/user/fans/:subscribeid',app.middleware.jwtValidator(false),controller.user.fanslist)
  //video 
  router.get('/video/getvod',app.middleware.jwtValidator(),controller.video.getvod)
  router.post('/video/upload',app.middleware.jwtValidator(),controller.video.upload)
  router.get('/video/list',app.middleware.jwtValidator(false),controller.video.list)
  router.get('/video/:vodid',app.middleware.jwtValidator(),controller.video.videodetail)

  //comments
  router.post('/comments/:videoid',app.middleware.jwtValidator(),controller.comments.add)
  router.delete('/comments/:commentid',app.middleware.jwtValidator(),controller.comments.delete)
  router.get('/comments/:videoid',app.middleware.jwtValidator(false),controller.comments.getcommentlist)

  //like
  router.put('/like/:videoid',app.middleware.jwtValidator(),controller.like.like)
  router.get('/like/list',app.middleware.jwtValidator(),controller.like.list)
  router.get('/dislike/:videoid',app.middleware.jwtValidator(),controller.like.dislike)

  //hotc
  router.get('/hotc',app.middleware.jwtValidator(false),controller.redis.getHotc)

  //test
  router.get('/test',app.middleware.jwtValidator(false),controller.test.test)
};
